/*
 * @Author: shawnXiao
 * @Date: 2021-12-18 21:16:31
 * @LastEditTime: 2021-12-19 22:45:25
 * @FilePath: /vue3-vite2-ts-antdv/src/router/index.ts
 */

import { createRouter,createWebHashHistory,RouteRecordRaw} from "vue-router";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/home",
    name: "Home",
    component: () => import('../views/Home/index.vue'),
        meta: {
      title: '疫情面板',
      icon: '',
      noCache: true,
      hidden: false,
      permissions: []
    }
  },
  {
    path: '/403',
    name: '403',
    meta: {
      title: '403',
      icon: '',
      noCache: true,
      hidden: true,
      permissions: []
    },
    component: () => import('../views/Error/403.vue')
  },
  {
    path: '/404',
    name: '404',
    meta: {
      title: '404',
      icon: '',
      noCache: true,
      hidden: true,
      permissions: []
    },
    component: () => import('../views/Error/404.vue')
  },
    // vue3对404配置进行了修改,必须要使用正则匹配
  { path: '/:pathMatch(.*)*', redirect: '/404' },
  { path: '', redirect: '/home' }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: routes
})

router.beforeEach((to, from) => {
    // to.path = '/login'
    return true
})

export default router;
